/*
 * Copyright (c) 2019 xiaofan <xfan1024@live.com>
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author          Notes
 * 2019-09-19     xiaofan         the first version
 */

#ifndef __MODEM_CHAT_H__
#define __MODEM_CHAT_H__
#include <Arduino.h>
#include<HardwareSerial.h>
#include<core_debug.h>
#define MODEM_CHAT_RESP_LIST(F) \
    F(MODEM_CHAT_RESP_OK,         "OK"), \
    F(MODEM_CHAT_RESP_READY,      "READY"), \
    F(MODEM_CHAT_RESP_CONNECT,    "CONNECT"), \
    F(MODEM_CHAT_RESP_BUSY,       "BUSY"), \
    F(MODEM_CHAT_RESP_NO_CARRIER, "NO CARRIER"), \
    F(MODEM_CHAT_RESP_ERROR,      "ERROR") \

#define DEFINE_MODEM_RESP_ID_TABLE(id, s) id

enum {
    MODEM_CHAT_RESP_LIST(DEFINE_MODEM_RESP_ID_TABLE),
    MODEM_CHAT_RESP_MAX,
    MODEM_CHAT_RESP_NOT_NEED,
};
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;
struct modem_chat_data {
    const char* transmit;
    u8 expect;      // use CHAT_RESP_xxx
    u8 retries;
    u8 timeout;     // second
    u8  ignore_cr;   // ignore CR character if it is 1
};

int modem_chat(HardwareSerial * serial, const struct modem_chat_data *data, u32 len);

#endif  /* __MODEM_CHAT_H__ */
